import React from 'react';
import { NavBar } from 'antd-mobile';
import styles from './index.less';

const empty = require('is-empty');
class NavBarItem extends React.Component {
  constructor(props) {
    super(props);
    this.state = {}
  }

  onLeftClick = () => {
    this.context.router.goBack();
  };

  render() {
    return (
      <div>
        <NavBar
          className={styles.navBarBorderBottom}
          mode={empty(this.props.mode) ? 'light' : this.props.mode}
          leftContent={empty(this.props.leftContent) ? '返回' : this.props.leftContent}
          onLeftClick={this.props.onLeftClick ? this.props.onLeftClick : this.onLeftClick}
          rightContent={empty(this.props.rightContent) ? null : this.props.rightContent}
        >
          {this.props.title}
        </NavBar>
      </div>
    )
  }
}

NavBarItem.contextTypes = {
  router: React.PropTypes.object
};
export default NavBarItem;
